package cn.cas.mango.Db;

import cn.cas.mango.dto.param.News;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ClusterWithScore {
  private Map<String, Double> neighbors;
  private String id;
  private String clusterId;


  public static List<ClusterWithScore> wrapList(Map<String, Map<String, Double>> map2Score,
                                         Map<String, News> newsMap) {
    List<ClusterWithScore> list = new ArrayList<>();
    for (String id: map2Score.keySet()) {
      Map<String, Double> neighbors = map2Score.get(id);
      String clusterId = newsMap.get(id).getClusterId();
      list.add(new ClusterWithScore(neighbors, id, clusterId));
    }
    return list;

  }

}
